home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / host / RCS / Host_ByInetAddr.c,v < prev    next >
Encoding:
Text File  |  1992-06-05  |  1.9 KB  |  88 lines

  1. head     1.1;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    jhh:1.1; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.1
  10. date     88.06.30.11.06.43;  author ouster;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @@
  17.  
  18.  
  19.  
  20. 1.1
  21. log
  22. @Initial revision
  23. @
  24. text
  25. @/* 
  26.  * Host_ByInetAddr.c --
  27.  *
  28.  *    Source code for the Host_ByInetAddr library procedure.
  29.  *
  30.  * Copyright 1988 Regents of the University of California
  31.  * Permission to use, copy, modify, and distribute this
  32.  * software and its documentation for any purpose and without
  33.  * fee is hereby granted, provided that the above copyright
  34.  * notice appear in all copies.  The University of California
  35.  * makes no representations about the suitability of this
  36.  * software for any purpose.  It is provided "as is" without
  37.  * express or implied warranty.
  38.  */
  39.  
  40. #ifndef lint
  41. static char rcsid[] = "$Header: proto.c,v 1.2 88/03/11 08:39:08 ouster Exp $ SPRITE (Berkeley)";
  42. #endif not lint
  43.  
  44. #include <stdio.h>
  45. #include <host.h>
  46. #include <hostInt.h>
  47.  
  48.  
  49. /*
  50.  *-----------------------------------------------------------------------
  51.  *
  52.  * Host_ByInetAddr --
  53.  *
  54.  *    Find information about the host with the given internet address.
  55.  *
  56.  * Results:
  57.  *    A Host_Entry structure, or NULL if no host exists in the database
  58.  *    with the given internet address.  The Host_Entry is statically
  59.  *    allocated, and may be modified on the next call to any Host_
  60.  *    procedure.
  61.  *
  62.  * Side Effects:
  63.  *    The host database file is opened if it wasn't already.
  64.  *
  65.  *-----------------------------------------------------------------------
  66.  */
  67.  
  68. Host_Entry *
  69. Host_ByInetAddr(inetAddr)
  70.     register struct in_addr inetAddr;    /* Address to match. */
  71. {
  72.     register Host_Entry            *entry;
  73.  
  74.     if (Host_Start() == 0) {
  75.     while (1) {
  76.         entry = Host_Next();
  77.         if (entry == (Host_Entry *) NULL) {
  78.         return (Host_Entry *) NULL;
  79.         }
  80.         if (entry->inetAddr.s_addr == inetAddr.s_addr) {
  81.         return (entry);
  82.         }
  83.     }
  84.     }
  85.     return ((Host_Entry *)NULL);
  86. }
  87. @
  88.